﻿using System;
using System.Web;
using Cms.Application.Admin.Presenters;
using Cms.Application.Admin.Views;
using Cms.Web.Framework.Controls;

namespace Cms.Web.UI.Admin
{
    public partial class ProcessUploadedFile : AdminPopupBasePage, IProcessUploadedFileView
    {
        private ProcessUploadedFilePresenter _presenter;

        public void RemoveFileFromOutputCache(string virtualPath)
        {
            HttpContext.Current.Cache.Insert(virtualPath, "remove", null, DateTime.Now.AddDays(-1), TimeSpan.Zero);
        }

        protected override void OnLoad(EventArgs e)
        {
            base.OnLoad(e);
            _presenter = new ProcessUploadedFilePresenter(this);
            HttpPostedFile postedFile = Request.Files["Filedata"];
            if (postedFile == null || postedFile.ContentLength == 0)
                return;
            _presenter.SaveUploadedFile(postedFile);
        }
    }
}